/**
 * 对接口返回的blob对象，处理之后下载文件
 * @param data
 * @param name
 */
export function downloadExcelByAxios(data: BlobPart, name: string) {
  return new Promise((resolve) => {
    const blob = new Blob([data], {
      type: 'application/vnd.ms-excel',
    });
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = url;
    a.download = name + '.xls';
    document.body.append(a);
    a.click();
    window.URL.revokeObjectURL(url);
    // 删除元素
    a.remove();
    resolve(true);
  });
}
